//
//  BYServiceTableViewCell.m
//  ZhiHuiLiJiang
//
//  Created by Work on 2018/11/25.
//  Copyright © 2018年 WisdomLijiang. All rights reserved.
//服务标题tableViewCell

#import "BYServiceTableViewCell.h"

@implementation BYServiceTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = RGBA(246, 246, 246, 1);
        [self addView];
    }
    return self;
}
- (void)addView{
    [self.contentView addSubview:self.backView];
    [self.contentView addSubview:self.titleLabel];
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(-15);
        make.left.mas_equalTo(self.contentView.mas_left).with.offset(2);
        make.top.mas_equalTo(self.contentView.mas_top).with.offset(15);
        make.width.mas_equalTo(@2);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.right.mas_equalTo(self.contentView.mas_right);
        make.left.mas_equalTo(self.backView.mas_right);
        make.height.mas_equalTo(@20);

    }];
}
- (UIView *)backView{
    if (!_backView) {
        _backView = [[UIView alloc] init];
        _backView.backgroundColor = [UIColor redColor];
    }
    return _backView;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont systemFontOfSize:12];
        _titleLabel.textColor = RGBA(52, 52, 52, 1);
    }
    return _titleLabel;
}
-(void)setModel:(BYserverMuneModel *)model{
    self.titleLabel.text  = model.decrp;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
    NSLog(@"服务表达选中：%@",selected?@"YES":@"NO");
    [super setSelected:selected animated:animated];
        if (selected == YES) {
            self.backView.hidden = NO;
            self.backView.backgroundColor = [UIColor redColor];
            self.contentView.backgroundColor = [UIColor whiteColor];
        }else{
            self.backView.hidden = YES;
            self.backView.backgroundColor = [UIColor redColor];
            self.contentView.backgroundColor = RGBA(246, 246, 246, 1);
        }
}


@end
